/*
 * DrawableInterface.cpp
 *
 *  Created on: Jul 1, 2009
 *      Author: kurt
 */

#include "DrawableInterface.h"
#include "DrawingCanvas.h"
using namespace std;
using namespace objdraw;

DrawableInterface::~DrawableInterface() 
{
	
}
DrawableInterface::DrawableInterface(const DrawableInterface & r)
{
	start = r.start;
	color = r.color;
	hidden = r.hidden;
	canvas = r.canvas;
	if(canvas != NULL)
		canvas->getCanvasContent().addDrawable(this);
}
DrawableInterface::DrawableInterface() 
{
	start = Location(0,0);
	color = Color(0,0,0);
	hidden = false;
	canvas = NULL;
}
void DrawableInterface::addToCanvas(DrawingCanvas * c)
{
	if(c == NULL) return;
	if(canvas != NULL) 
		canvas->getCanvasContent().removeDrawable(this);
	canvas = c;
	canvas->getCanvasContent().addDrawable(this);
}
bool DrawableInterface::contains(Location point)
{
	if(start == point)
		return true;
	return false;
}
DrawingCanvas * DrawableInterface::getCanvas() 
{ 
	return canvas; 
}
Color DrawableInterface::getColor() 
{ 
	return color; 
}
void DrawableInterface::setColor(Color c) 
{ 
	color = c; 
}
void DrawableInterface::hide() 
{ 
	hidden = true; 
}
void DrawableInterface::show() 
{ 
	hidden = false;
}
bool DrawableInterface::isHidden() 
{ 
	return hidden; 
}
void DrawableInterface::move(float dx, float dy) 
{ 
	start.translate(dx,dy);
}
void DrawableInterface::moveTo(float x, float y) 
{ 
	start.moveTo(x,y);
}
void DrawableInterface::moveTo(Location point) 
{ 
	start = point;
}
void DrawableInterface::removeFromCanvas()
{
	if(canvas == NULL) return;
	canvas->getCanvasContent().removeDrawable(this);
}
void DrawableInterface::sendBackward()
{
	if(canvas == NULL) return;
	canvas->getCanvasContent().sendBackward(this);
}
void DrawableInterface::sendForward()
{
	if(canvas == NULL) return;
	canvas->getCanvasContent().sendForward(this);
}
void DrawableInterface::sendToBack()
{
	if(canvas == NULL) return;
	canvas->getCanvasContent().sendToBack(this);
}
void DrawableInterface::sendToFront()
{
	if(canvas == NULL) return;
	canvas->getCanvasContent().sendToFront(this);
}
void DrawableInterface::render()
{
	
}
std::string DrawableInterface::toString()
{
	return "DrawableInterface";
}
bool DrawableInterface::operator ==(DrawableInterface d)
{
	if( d.color == color &&
		d.hidden == hidden &&
		d.start == start)
		return true;
	return false;
}
